/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Common;

import java.io.Serializable;
import java.util.Objects;

/**
 *
 * @author Samsung
 */
public class Message implements Serializable  {
   
    private Comunication comunication;
    private Detail detail;
    
    public Message() {
        
    }

    public Message(Comunication comunication, Detail detail) {
        this.comunication = comunication;
        this.detail = detail;
    }

    public Message(String sender, String receiver, String subject, String body) {
        
        comunication=new Comunication(sender, receiver);
        detail =new Detail(subject, body);
       
    }

    @Override
    public String toString()
    {
        return comunication+", " + detail;
                
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(this.detail);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Message other = (Message) obj;
        return Objects.equals(this.detail, other.detail);
    }
    
    public Long getUniqueId() {
        
        return null;
    }

    public void delete() {
        detail.updateEmailStatus(EmailStatusType.DELETED);
    }
        
    public EmailStatusType retrieveEmailCurrentStatus() {
        return detail.retrieveEmailCurrentStatus();
    }

    public Comunication getComunication() {
        return comunication;
    }

    public void setComunication(Comunication comunication) {
        this.comunication = comunication;
    }

    public Detail getDetail() {
        return detail;
    }

    public void setDetail(Detail detail) {
        this.detail = detail;
    }
    
    
}
